
package com.saturday.uid.worker.service.impl;

import com.saturday.uid.worker.dao.WorkerNodeDao;
import com.saturday.uid.worker.service.WorkerIdAssigner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 可复用的workerId
 * 注：可复用的workerId时，可适当减少workerBits位数
 */
@Service
public class RepeatableWorkerIdAssigner implements WorkerIdAssigner {

    @Autowired
    private WorkerNodeDao workerNodeDao;

    /**
     * 分配一个可复用的workerId
     * 
     * @return assigned worker id
     */
    @Override
    public long assignWorkerId() {
        return workerNodeDao.assignRepeatableWorkerId();
    }

}
